import 'dart:ui';

/// @Title  获取用户vip信息
/// @Author: bryce
/// @CreateDate: 2023年12月01日00:07:37
class GTVipUtils {
  /// 通过tier获取vip等级
  static int getVipLevelByTier(String? tier) {
    if (tier == null) return 0;
    return int.tryParse(tier.contains("-") ? tier.split("-")[1] : tier) ?? 0;
  }

  /// 根据tier获取vip等级本地图片
  static String getVipAssetImageByTier(String? tier) {
    if (tier == null) return "";
    int vipLevel = getVipLevelByTier(tier);
    return getVipAssetImageByVipLevel(vipLevel);
  }

  /// 根据vip等级获取vip等级本地图片
  static String getVipAssetImageByVipLevel(int vipLevel) {
    if (vipLevel <= 0) vipLevel = 0;
    if(vipLevel > 20) vipLevel = 20;
    return "packages/lib_uikit/assets/images/vip/icon_level_vip$vipLevel.png";
  }

  /// 根据tier等级获取vip等级颜色
  static Color getVipColorByVipTier(String? tier){
    int vipLevel = getVipLevelByTier(tier);
    return getVipColorByVipLevel(vipLevel);
  }

  /// 根据vip等级获取vip等级颜色
  static Color getVipColorByVipLevel(int vipLevel) {
    if (vipLevel <= 0) vipLevel = 0;
    if(vipLevel > 20) vipLevel = 20;
    return vipColors[vipLevel];
  }

  /// vip等级颜色
  static List<Color> vipColors = [
    const Color(0xFF7E8691),
    const Color(0xFF6783AA),
    const Color(0xFF5487CD),
    const Color(0xFF5096F7),
    const Color(0xFF28AFF2),
    const Color(0xFF1AC7E7),
    const Color(0xFF18C5C1),
    const Color(0xFF17C69F),
    const Color(0xFF16C278),
    const Color(0xFFFFBA00),
    const Color(0xFFFFA605),
    const Color(0xFFFF933D),
    const Color(0xFFFF8032),
    const Color(0xFFFF692B),
    const Color(0xFFFC3932),
    const Color(0xFF6176F6),
    const Color(0xFF8971FE),
    const Color(0xFF9B55EC),
    const Color(0xFFBE4AC9),
    const Color(0xFFBE4AC9),
    const Color(0xFFBE4AC9),
  ];
}
